<?php
//判断是否在配置页面
$iscnf = false;
if (count(explode('/cnf/', get_controller())) > 1) {
    $iscnf = true;
}
?>

<!doctype html>
<html lang="zh" translate="no">

<head>
    <title>
        FrameCoder(非可)集约化平台
    </title>
    <meta charset="utf-8">
    <script src="/static/admin/lib/jquery/jquery.min.js"></script>
    <link href="/static/admin/css/theme.css" rel="stylesheet">
    <style>
        <?php if ($crumb[0]['belong'] == 2) {
        ?> :root {
            --primary-color: #016243
        }

        <?php
        } ?>
    </style>
    <link href="/static/admin/css/rovecoder.css" rel="stylesheet" />
    <link href="/static/admin/lib/layui/css/layui.css" rel="stylesheet">
    <script src="/static/admin/lib/layui/layui.js"></script>
    <script src="/static/admin/lib/toastr/toastr.min.js"></script>
    <link href="/static/admin/lib/toastr/toastr.min.css" rel="stylesheet">
    <script src="/static/admin/js/rovecoder.js"></script>

</head>

<body>
    <div class="layui-fluid rc-layout  ">
        <div class="header rc-flex rc-flex-justify-between">
            <div class="logo">
                <img src="/static/admin/images/logo.png" />
            </div>

            <div class="quick-bar rc-flex1">
                <div class="rc-flex rc-flex-justify-between rc-flex-vertical-center">
                    <div class="  rc-flex rc-flex-vertical-center">
                        <?php if ($iscnf) {
                        ?>
                            <a href="javascript:;">
                                <span>系统配置</span>

                            </a>
                        <?php
                        } else {
                        ?>
                            <div class="rc-text-color-grey rc-dropdown-btn">
                                <a href="javascript:;">
                                    <span><?php echo now_site()['title']; ?></span>
                                    <i class="layui-icon layui-icon-down layui-font-12"></i>
                                </a>
                                <div class="layui-hide rc-dropdown">
                                    <?php foreach ($manageablesites as $site) {
                                    ?>
                                        <a class="item" href="//<?php echo $site['domain'] ?>/admin/Index/index">
                                            <i class="iconfont">&#xe68f;</i> <?php echo $site['title'] ?>
                                        </a>
                                        <div class="drive"></div>
                                    <?php
                                    } ?>


                                </div>
                            </div>
                        <?php
                        } ?>

                    </div>

                    <div class="rc-flex rc-flex-center">




                        <?php
                        if (session('admininfo')['issystem']) {
                        ?>
                            <div class="quick-op-btn">
                                <div class="">
                                    <?php
                                    if ($iscnf) {
                                    ?>
                                        <a href="/admin/Index/index" title="站点管理">
                                            <i class="iconfont">&#xe68f;</i>
                                        </a>
                                    <?php
                                    } else {
                                    ?>
                                        <a title="全局设置" href="/admin/cnf/UserLogregConfig/index">
                                            <i class="iconfont">&#xe643;</i>
                                        </a>
                                    <?php
                                    }
                                    ?>

                                </div>
                            </div>
                        <?php
                        }
                        ?>



                        <div class="quick-op-btn">

                            <div class="rc-dropdown-btn">
                                <a>
                                    <i class="iconfont">&#xe61d;</i>
                                </a>
                                <div class="layui-hide rc-dropdown">


                                    <a class="item" id="changepwd">
                                        <i class="iconfont icon-wenbenshuru"></i> 修改密码
                                    </a>
                                    <div class="drive"></div>
                                    <a class="item" href="/uc/Logreg/logout">
                                        <i class="iconfont icon-fanhui2"></i> 退出登录
                                    </a>
                                </div>
                            </div>


                        </div>

                    </div>
                </div>

            </div>


        </div>





        <div class="main  rc-flex rc-flex-justify-between ">
            <div class="menus rc-flex">
                <div class="module-menus">
                    <?php

                    foreach ($firstMenuNode->getSiblingsAndSelf() as $sibling) {
                        $url = $sibling->url;
                        if ($sibling->hasChildren()) {
                            $secmenus = $sibling->getChildren();
                            if ($secmenus[0]->url != '') {
                                $url = $secmenus[0]->url;
                            } else {
                                if ($secmenus[0]->hasChildren()) {
                                    $thirdmenus = $secmenus[0]->getChildren();
                                    $url = $thirdmenus[0]->url;
                                }
                            }
                        }


                    ?>
                        <a class="<?php echo $sibling->id == $crumb[0]['id'] ? 'active' : '' ?>" href="<?php echo $url; ?>">
                            <i class="iconfont <?php echo $sibling->icon; ?>"></i>
                            <div class="text"><?php echo $sibling->title; ?></div>
                        </a>
                    <?php
                    }
                    ?>
                </div>


                <?php
                if ($firstMenuNode->hasChildren()) {
                ?>
                    <div class="child-menus">
                        <div style="padding: 24px 16px;">
                            <h2 class="bigtitle"><?php echo $crumb[0]['title']; ?></h2>
                            <?php
                            $secmenus = $firstMenuNode->getChildren();
                            foreach ($secmenus as $secmenu) {
                            ?>
                                <div class="secmenu">
                                    <a href="<?php echo $secmenu->url == '' ? 'javascript:;' :  $secmenu->url; ?>" class="<?php echo isset($crumb[1]) && $secmenu->id == $crumb[1]['id'] ? 'active' : '' ?>"> <i class="iconfont <?php echo $secmenu->icon ?>"></i><?php echo $secmenu->title ?></a>
                                </div>
                                <div class="thriemenu">
                                    <?php
                                    $thridmenus = $secmenu->getChildren();
                                    foreach ($thridmenus as $thridmenu) {
                                    ?>
                                        <a href="<?php echo $thridmenu->url == '' ? 'javascript:;' :  $thridmenu->url; ?>" class="<?php echo isset($crumb[2]) && $thridmenu->id == $crumb[2]['id'] ? 'active' : '' ?>">
                                            <div class="rc-flex rc-flex-justify-between rc-flex-vertical-center ">
                                                <span><?php echo $thridmenu->title ?></span>

                                            </div>
                                        </a>
                                    <?php
                                    }
                                    ?>
                                </div>
                            <?php
                            }
                            ?>
                        </div>
                    </div>
                <?php
                }
                ?>


            </div>
            <div class="rc-flex1">
                <div class="rc-crumb" style="display:none">
                    <span class="layui-breadcrumb">

                    </span>
                </div>

                <?php include $template ?>
            </div>
        </div>


        <!---框架版本检查提示-->
        <?php
        if (request()->cookie('showFrameTips_box', 0) != 1) {
            if (config('frame.nextversion') != '') {
        ?>
                <div class="rc-bg-grey" id="FrameTips_box" style="padding-bottom: 0;position: fixed;width: 100%; bottom:0;color:#fff">
                    <div>
                        <div class="rc-pagepadding" style="background:#2d2b27;text-align:center">
                            框架有新版本，建议您更新到最新版本，以获得更好的用户体验。
                            <a href="/admin/cnf/Frame/index" style="color:#fff" class=" rc-bold">立即更新</a>

                            <i class="layui-icon layui-icon-error " id="closeFrameTips" style="font-size: 18px; margin-left:15px;cursor: pointer;"></i>
                        </div>
                    </div>
                </div>
        <?php
            }
        }
        ?>



    </div>


    <!--修改密码-->
    <div id="changepwddiv" class="layui-hide">
        <form class="layui-form" lay-filter="login-form" style="margin: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label">旧密码</label>
                <div class="layui-input-block">
                    <input type="password" name="oldpwd" id="oldpwd" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input type="password" name="newpwd" id="newpwd" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-block">
                    <input type="password" name="renewpwd" id="renewpwd" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>

            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="changepwd_submit">修改</button>
                </div>

            </div>
        </form>
    </div>
    <script>
        layui.use(function() {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            $(document).on('click', '#changepwd', function() {
                layer.open({
                    type: 1,
                    title: '修改密码',
                    area: ['420px', '300px'], // 宽高
                    content: $('#changepwddiv').html()
                });
            })

            form.on('submit(changepwd_submit)', function(data) {
                var data = data.field;
                $.ajax({
                    url: "/admin/Personal/changepwd", //请求路径
                    type: "POST", //请求方式
                    data: data,
                    success: function(data) {
                        if (data.code == 0) {
                            toastr_success("修改成功", function() {
                                layer.closeAll();
                            });
                        } else {
                            toastr_error(data.message);
                        }
                    },
                    error: function() {

                    },

                });
            });

            $('#closeFrameTips').click(function() {
                document.cookie = "showFrameTips_box=1;path=/; ";
                $('#FrameTips_box').hide();
            });
        });
    </script>
</body>

</html>